package com.csgc.camera.widget.mask

import android.content.Context
import android.graphics.Color
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView

import com.csgc.camera.constants.MaskConfig
import com.csgc.camera.storage.MaskPreference
import com.cysd.spsyxj.R


class MaskScene:MaskBase {

    constructor(context: Context?, id:Int) : super(context,null){
        if(id == 0){
            dateStyle = "yyyy-MM-dd EEEE"
            LayoutInflater.from(context).inflate(R.layout.item_mask_scene_1, this, true)
        }

        if(MaskConfig.maskDateStyle.isNotEmpty()){
            dateStyle = MaskConfig.maskDateStyle
        }
        initView()

    }

    private fun initView(){

        date = findViewById(R.id.tv_scene_date)
        location = findViewById(R.id.tv_scene_location)
        remark = findViewById(R.id.tv_scene_remark)
        customMaskContainer = findViewById(R.id.layout_custom_mask_container)

        location?.text = MaskConfig.maskLocation
        changeDateTime()
        MaskConfig.customMaskInfo.forEach {
            val text = TextView(context)
            text.setTextColor(Color.WHITE)
            text.setTextSize(TypedValue.COMPLEX_UNIT_SP,14f)
            text.text = "${it.title}:${it.content}"
            text.visibility = if (it.isOpen) View.VISIBLE else View.GONE

            customMaskContainer?.addView(text)
        }

        val maskType = MaskPreference.instance.getMaskType()
        MaskConfig.maskMap[maskType]?.forEach {
            if(it.title == "备注"){
                remark?.text = "${it.title}:${it.content}"
                remark?.visibility = if(it.isOpen) View.VISIBLE else View.GONE
            }
        }



    }

}